package com.emm.yixun.common.page;

import java.io.Serializable;
import java.util.List;

public class Page <T> implements Serializable {
	private static final long serialVersionUID = 1L;

	private long total = 0;

	private List<T> rows = null;
	
	private long totalPages = 0;
	
	private int pageNumber = 0;
	
	private int pageSize = 0;
	
	private String errorMsg;
	private String error;
	
	private Boolean success;
	
	public void setPageInfo(long total,int begin,int end){
		this.total = total;
		setPageSize(end-begin);
		if(pageSize>0&&end%pageSize==0){
			this.pageNumber = end/pageSize;
		}else{
			this.pageNumber = (end - end%pageSize)/pageSize + 1;
		}
	}
	
	public String getErrorMsg() {
		return errorMsg;
	}

	public void setErrorMsg(String errorMsg) {
		this.errorMsg = errorMsg;
	}

	public void setTotalPages(long totalPages) {
		this.totalPages = totalPages;
	}

	public Page() {
		super();
	}

	public Page(long total, List<T> rows) {
		super();
		this.total = total;
		this.rows = rows;
	}

	public long getTotal() {
		return total;
	}

	public void setTotal(long total) {
		this.total = total;
	}

	public List<T> getRows() {
		return rows;
	}

	public void setRows(List<T> rows) {
		this.rows = rows;
	}

	public long getTotalPages() {
		return totalPages;
	}

	public int getPageNumber() {
		return pageNumber;
	}

	public void setPageNumber(int pageNumber) {
		this.pageNumber = pageNumber;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
		if(pageSize>0&&total%pageSize==0){
			this.totalPages = total/pageSize;
		}else{
			this.totalPages = (total - total%pageSize)/pageSize + 1;
		}
	}

	public Boolean getSuccess() {
		return success;
	}

	public void setSuccess(Boolean success) {
		this.success = success;
	}

	public String getError() {
		return error;
	}

	public void setError(String error) {
		this.error = error;
	}
	
	
}
